import { getMobileInboundDict } from "@/api/system/dict.js";

const purchase = {
  state: {
    productList: [],
    mobileInboundList: [],
  },

  mutations: {
    SET_PRODUCT_LIST: (state, productList) => {
      state.productList = productList;
    },
    setMobileInboundList: (state, list) => {
      state.mobileInboundList = list;
    },
  },

  actions: {
    FetchMobileInbound({ commit }) {
      getMobileInboundDict().then((res) => {
        const { data } = res;
        const list = data?.map((item) => ({
          value: item.dictValue,
          text: item.dictLabel,
          ...item,
        }));
        commit("setMobileInboundList", list || []);
      });
    },
  },
};

export default purchase;
